<?php
function htmlspec($src) {
	return htmlspecialchars($src, ENT_COMPAT, 'UTF-8');
}

function make_blog_url($blogger_id, $user_url) {
	if(is_null($user_url) || strlen($user_url) == 0) {
		return '/' . $blogger_id;
	} else {
		return '/' . $user_url;
	}
}

function get_avatar_name($user_id, $rand) {
	$fn = $_SERVER['DOCUMENT_ROOT'] . '/img/avatars/avt_' . $user_id . '_48x48.jpg';
	if(file_exists($fn)) {
		if($rand) {
			return 'avt_' . $user_id . '_48x48.jpg?R=' . rand();
		} else {
			return 'avt_' . $user_id . '_48x48.jpg';
		}
	} else {
		return 'avt_-1_48x48.jpg';
	}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<title><?php echo($this->config->item('SiteTitle')); ?></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="apple-touch-icon" href="/img/iphone-icon.png" />
<link rel="stylesheet" type="text/css" href="/css/iphone.css" />
</head>
<body>
	<div id="wrapper">
		<div id="hdr">
			<h1><?php echo($this->config->item('SiteTitle')); ?></h1>
		</div>
		<div id="bdy">
			<?php foreach($bloggers as $bl) { ?>
			
			<div class="mbr">
				<a href="<?php echo(make_blog_url($bl->id, $bl->user_url)); ?>">
					<div class="avt"><img alt="" src="/img/avatars/<?php echo(get_avatar_name($bl->id, $avatar_refresh)); ?>" border="0" /></div>
					<div class="ath"><?php echo(htmlspec($bl->user_name)); ?></div>
				</a>
			</div>
			
			<?php } ?>
			<div class="z"></div>
		</div>
		<?php
		include('common_footer.php');
		?>
	</div>
<!-- JS -->
<script type="text/javascript" src="/js/3rd/jquery.pack.js"></script>
<script type="text/javascript" src="/js/iphone.js"></script>
<script type="text/javascript">
$(document).ready(function() {
	initPage4iPhone();
});
</script>
<!-- /JS -->
</body>
</html>